BC_Notify = {
	defaultOpt: {
		title: "",
		msg: "",
		type: "notify",
		mask: true,
		timeInterval: 0,
		loadingImg: BCConfig.url + "images/loading.gif"
	},
	loadingImg: BCConfig.url + "images/loading.gif",
	options: {},
	index: 0,
	show: function(option) {
		option = BC_Notify.setOption(option);
		var index = option.index;
		var html = BC_Notify.notifyHtml();
		$("body").append(html);
		if(option.timeInterval > 0) {
			option.interval = setInterval(function(index) {
				var opt = BC_Notify.options[index];
				opt.timeInterval = opt.timeInterval - 1;
				if(opt.timeInterval < 0) {
					BC_Notify.close(index);
					if(typeof opt.interval != "undefined") {
						window.clearInterval(opt.interval);
					}
				}
				$(".bc_notify.index_" + index + " .timeInterval").html(opt.timeInterval + "s");
			}, 1000, index)
		} else if(!option.mask){
			option.timeoutIndex = setTimeout(BC_Notify.close, 10*1000, index);
		}else if(option.mask){
			option.timeoutIndex = setTimeout(function(i){
				if(BC_Notify.options[i] == null)return;
				var data = BC_Notify.options[i];
				BC_Notify.close(i);
				if(data.actions && data.actions.length >1){
					data.actions[1].func();
				}
			}, 30*1000, index);
		}
		return index;
	},
	click:function(index){
		var opt = BC_Notify.options[index+""];
		if(opt&& opt.actions && opt.actions.length > 0){
		}else{
			BC_Notify.close(index);
		}
		
	},
	close: function(index) {
		BC_Notify.options[index+""] = null;
		var html = BC_Notify.notifyHtml();
		$(".bc_notify").remove();
		$("body").append(html);
	},
	closeAll: function() {
		BC_Notify.options = {};
		var html = BC_Notify.notifyHtml();
		$(".bc_notify").remove();
		$("body").append(html);
	},
	notifyHtml: function() {
		var html = template("notifyViewTmp", BC_Notify);
		return html;
	},
	setOption: function(option) {
		var string = JSON.stringify(BC_Notify.defaultOpt);
		var op = JSON.parse(string);
		for(var p in option) {
			op[p] = option[p];
		}
		option = op;

		for(var i = 0; i < 100; i++) {
			BC_Notify.index = (BC_Notify.index + 1) % 1000;
			var index = BC_Notify.index;
			if(typeof BC_Notify.options[index + ""] != "undefined" && BC_Notify.options[index + ""] != null) {}
			else{
				option.index = index;
				BC_Notify.options[index + ""] = option;
				return option;
			}
		}
		
	},
}